package lab5p2;

import javax.swing.JFrame;

import java.awt.Graphics;
import java.awt.Graphics2D;

import lab5p1.Rectangle;

/**
 * Title: RectangleGUI class for CSIS 235 Lab 5
 * Description: CS 235 Lab #5
 *    Basic GUI class that draws Rectangle objects.
 * 
 * @author Anthony Varghese
 * @email anthony.varghese@my.uwrf.edu
 * @author 
 * @email 
 * @author 
 * @email 
 * @author 
 * @email 
 * @date September 3rd 2014
 * @version 1.0
 */

public class RectangleGUI extends JFrame {

	/**
	 * main - this is where the program starts
	 * @param args
	 */
	public static void main(String[] args) {
		new RectangleGUI("Rectangles");

	}

	/**
	 * Class data members:
	 * Default serial version id
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Instance data members
	 */
	private Rectangle rectangle1;
	private Rectangle rectangle2;
	private Rectangle rectangle3;
	private Rectangle rectangle4;

	/**
	 * Constructor with a String to be used as the title
	 * @param string
	 */
	public RectangleGUI(String title) {
		setTitle( title );
		setBounds( 100, 100, 400, 300);
		
		rectangle1 = new Rectangle( 105, 40, 50, 130 );
		rectangle2 = new Rectangle( -10, -30, 200, 100 );
		rectangle3 = new Rectangle( );
		rectangle4 = new Rectangle( rectangle1 );
		
		setDefaultCloseOperation( EXIT_ON_CLOSE );
		setVisible(true);
	}

	/**
	 * 
	 * paint method - this gets called whenever the window has to be "refreshed"
	 * Notice that it is not called anywhere in this program.
	 * 
	 * @see java.awt.Window#paint(java.awt.Graphics)
	 */
	@Override
	public void paint(Graphics g) {
		super.paint(g);
		Graphics2D g2d = (Graphics2D) g;
		
		rectangle1.draw( g2d );
		rectangle2.draw( g2d );
		rectangle3.draw( g2d );
		rectangle4.draw( g2d );
	}

}
